<?php
namespace app\common\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule =   [
        'id'                   => 'require|integer',
        'user_id|用户ID'       => 'require|integer',
        'page|页数'            => 'require|integer',
        'limit|条数'           => 'require|integer',
        'username|账号'        => 'require|length:6,20',
        'nickname|昵称'        => 'require|length:2,20',
        'mobile|联系方式'      => 'require|length:6,20',
        'avatar|头像'          => 'require',
        'wxcode'               => 'require|length:1,255',
        'session_key'          => 'require',
        'encrypted_data'       => 'require',
        'iv'                   => 'require',
        'scene'                => 'require',
    ];
    
    protected $scene = [
        /** 接口 */
        'openid'      => ['wxcode'],
        'wxlogin'     => ['openid', 'avatar', 'nickname', 'mobile'],
        'show'        => ['user_id'],
        'set_user'    => ['user_id', 'nickname'],
        'team'        => ['user_id', 'page', 'limit'],
        'decrypt'     => ['session_key', 'encrypted_data', 'iv'],
        'codeunlimit' => ['scene'],

        /** 后台 */
        'list'       => ['page', 'limit'],
    ];
}